home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / BitmapX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  6.1 KB  |  185 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. /* Define calls if using function pointers or not */
  40. #ifdef FUNCTION_PTRS
  41.   #if (COLOR_DIM == 3)
  42.     #define COLOR_CALL   (*color3fv)(srcPtr)
  43.   #else
  44.     #define COLOR_CALL   (*color4fv)(srcPtr)
  45.   #endif
  46.   #define INDEX_CALL   (*indexfv)(srcPtr)
  47.   #ifdef MULTIIMAGE
  48.     #define BITMAP_CALL   (*bitmap)(width, height, 0., 0., 0., 0., *imagePtr++);
  49.   #else
  50.     #define BITMAP_CALL   (*bitmap)(width, height, 0., 0., 0., 0., image);
  51.   #endif
  52.   #define PIXELSTORE_CALL  (*pixelStore)
  53.   #if (RASTERPOS_DIM == 2)
  54.     #define RASTERPOS_CALL   (*rasterPos2fv)(srcPtr); srcPtr += 2;
  55.   #else
  56.     #define RASTERPOS_CALL   (*rasterPos3fv)(srcPtr); srcPtr += 3;
  57.   #endif
  58. #else
  59.   #if (COLOR_DIM == 3)
  60.     #define COLOR_CALL   glColor3fv(srcPtr)
  61.   #else
  62.     #define COLOR_CALL   glColor4fv(srcPtr)
  63.   #endif
  64.   #define INDEX_CALL   glIndexfv(srcPtr)
  65.   #ifdef MULTIIMAGE
  66.     #define BITMAP_CALL   glBitmap(width, height, 0., 0., 0., 0., *imagePtr++);
  67.   #else
  68.     #define BITMAP_CALL   glBitmap(width, height, 0., 0., 0., 0., image);
  69.   #endif
  70.   #define PIXELSTORE_CALL  glPixelStorei
  71.   #if (RASTERPOS_DIM == 2)
  72.     #define RASTERPOS_CALL   glRasterPos2fv(srcPtr); srcPtr += 2;
  73.   #else
  74.     #define RASTERPOS_CALL   glRasterPos3fv(srcPtr); srcPtr += 3;
  75.   #endif
  76. #endif
  77.  
  78. #if (VISUAL == RGB)
  79.   #define COLOR_DATA COLOR_CALL; srcPtr += COLOR_DIM;
  80. #else
  81.   #define COLOR_DATA INDEX_CALL; srcPtr += 1;
  82. #endif
  83. #if (COLOR == PER_RASTERPOS)
  84.   #define RASTERPOS_COLOR_DATA COLOR_DATA
  85. #else
  86.   #define RASTERPOS_COLOR_DATA
  87. #endif
  88.  
  89. void FUNCTION (TestPtr thisTest)
  90. {
  91.     BitmapPtr this = (BitmapPtr)thisTest;
  92.     int iterations = this->iterations;
  93.     int numDrawn = this->numDrawn;
  94.     int width = this->bitmapWidth;
  95.     int height = this->bitmapHeight;
  96.   #ifdef SUBIMAGE
  97.     GLint imageWidth = this->image_Bitmap.imageWidth;
  98.   #endif
  99.     int i,j;
  100.   #ifdef MULTIIMAGE
  101.     int numObjects = this->numObjects;
  102.     int k;
  103.     void **imageData = this->imageData;
  104.     void **imagePtr = imageData;
  105.   #else
  106.     void *image = *(this->imageData);
  107.   #endif
  108.   #ifdef SUBIMAGE
  109.     GLint *subImageData = this->subImageData;
  110.     GLint *subPtr = subImageData;
  111.   #endif
  112.     GLfloat *traversalData = this->traversalData;
  113.     GLfloat *srcPtr = traversalData;
  114.   #ifdef FUNCTION_PTRS
  115.    #ifdef WIN32
  116.     #if (VISUAL == RGB)
  117.      #if (COLOR_DIM == 3)
  118.       void (APIENTRY *color3fv)(const GLfloat*) = glColor3fv;
  119.      #else
  120.       void (APIENTRY *color4fv)(const GLfloat*) = glColor4fv;
  121.      #endif
  122.     #else
  123.      void (APIENTRY *indexfv)(const GLfloat*) = glIndexfv;
  124.     #endif
  125.     void (APIENTRY *bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte*) = glBitmap;
  126.     void (APIENTRY *pixelStore)(GLenum, GLint) = glPixelStorei;
  127.     #if (RASTERPOS_DIM == 2)
  128.      void (APIENTRY *rasterPos2fv)(const GLfloat*) = glRasterPos2fv;
  129.     #else
  130.      void (APIENTRY *rasterPos3fv)(const GLfloat*) = glRasterPos3fv;
  131.     #endif
  132.    #else
  133.     #if (VISUAL == RGB)
  134.      #if (COLOR_DIM == 3)
  135.       void (*color3fv)(const GLfloat*) = glColor3fv;
  136.      #else
  137.       void (*color4fv)(const GLfloat*) = glColor4fv;
  138.      #endif
  139.     #else
  140.      void (*indexfv)(const GLfloat*) = glIndexfv;
  141.     #endif
  142.     void (*bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte*) = glBitmap;
  143.     void (*pixelStore)(GLenum, GLint) = glPixelStorei;
  144.     #if (RASTERPOS_DIM == 2)
  145.      void (*rasterPos2fv)(const GLfloat*) = glRasterPos2fv;
  146.     #else
  147.      void (*rasterPos3fv)(const GLfloat*) = glRasterPos3fv;
  148.     #endif
  149.    #endif
  150.   #endif
  151.  
  152.   #ifdef SUBIMAGE
  153.     PIXELSTORE_CALL(GL_UNPACK_ROW_LENGTH, imageWidth);
  154.   #endif
  155.     for (i = iterations; i > 0; i--) {
  156.     for (j = numDrawn; j > 0; j--) {
  157.       #ifdef SUBIMAGE
  158.         PIXELSTORE_CALL(GL_UNPACK_SKIP_PIXELS, *subPtr++);
  159.         PIXELSTORE_CALL(GL_UNPACK_SKIP_ROWS, *subPtr++);
  160.       #endif        
  161.         RASTERPOS_COLOR_DATA
  162.         RASTERPOS_CALL
  163.           #ifdef MULTIIMAGE
  164.         for (k = numObjects; k > 0; k--)
  165.           #endif
  166.         BITMAP_CALL
  167.           #ifdef MULTIIMAGE
  168.         imagePtr = imageData;
  169.           #endif
  170.     }
  171.     srcPtr = traversalData;
  172.       #ifdef SUBIMAGE
  173.     subPtr = subImageData;
  174.       #endif
  175.     }
  176. }
  177.  
  178. #undef BITMAP_CALL
  179. #undef PIXELSTORE_CALL
  180. #undef RASTERPOS_CALL
  181. #undef COLOR_DATA
  182. #undef COLOR_CALL
  183. #undef INDEX_CALL
  184. #undef RASTERPOS_COLOR_DATA
  185.